{include file="public_head" /}
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload_arr -->
<link href="__STATIC__/plupload/plupload.css" rel="stylesheet">
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- sku -->
<link href="__STATIC__/css/sku.css" rel="stylesheet" type="text/css">

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>店铺商品管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm">

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品名称：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品名称"
                                                   class="form-control col-md-7 col-xs-12" name="title"
                                                   value="{$item.title|default=''}"
                                                   datatype="*"
                                                   nullmsg="请输入商品名称！" errormsg="请输入商品名称！"
                                            >
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品属性：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品属性"
                                                   class="form-control col-md-7 col-xs-12" name="attribute"
                                                   value="{$item.attribute|default=''}"
                                                   datatype="*"
                                                   nullmsg="请输入商品属性！" errormsg="请输入商品属性！"
                                            >
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品材质：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品材质"
                                                   class="form-control col-md-7 col-xs-12" name="material"
                                                   value="{$item.material|default=''}"
                                                   datatype="*"
                                                   nullmsg="请输入商品材质！" errormsg="请输入商品材质！"
                                            >
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品保留价格：</label>
                                        <div class="col-md-2 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品保留价格"
                                                   class="form-control col-md-7 col-xs-12" name="reserve_price"
                                                   value="{$item.reserve_price|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品起拍价格：</label>
                                        <div class="col-md-2 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品起拍价格"
                                                   class="form-control col-md-7 col-xs-12" name="starting_price"
                                                   value="{$item.starting_price|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品保证金：</label>
                                        <div class="col-md-2 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品保证金"
                                                   class="form-control col-md-7 col-xs-12" name="bond"
                                                   value="{$item.bond|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品竞价金额：</label>
                                        <div class="col-md-2 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请输入商品竞价金额"
                                                   class="form-control col-md-7 col-xs-12" name="bidding"
                                                   value="{$item.bidding|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="divider-dashed"></div>


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">图片上传：【320*250】</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <div id="imgdiv">
                                                <img id="imgShow" src="__PUBLIC__/{$item.picUrl|default=''}"
                                                     width="200" height="190"
                                                     onerror="this.src='__STATIC__/images/default.png'"/>
                                            </div>
                                            <div class="uploader white">
                                                <input type="text" class="filename" name="picUrl"
                                                       value="{$item.picUrl|default=''}" readonly/>
                                                <input type="button" name="file" class="button" value="上传..."/>
                                                <input type="file" id="up_img" name="picUrl"
                                                       value='{$item.picUrl|default=""}'/>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">商品内容：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea type="text/plain" style="height: 300px;" id="containers"
                                                      name="content"
                                                      placeholder="请输入店铺商品内容">
                                                {$item.content|default=''}
                                            </textarea>
                                        </div>
                                    </div>
                                    <input type="hidden" name="auction_id" value='{$item.auction_id|default=""}'>
                                    <div class="divider-dashed"></div>


                                    <div class="ln_solid"></div>

                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            {present name="$item.id"}
                                            <input type="hidden" name="id" value="{$item.id}">
                                            {/present}
                                            <button type="submit" class="btn btn-primary">提交</button>
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- upload_arr -->
<script src="__STATIC__/js/upload.photos.js"></script>
<script type="text/javascript" src="__STATIC__/plupload/plupload.full.min.js"></script>
<!-- Times -->
<script src='__STATIC__/js/datepicker/WdatePicker.js'></script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- select -->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- upload -->
<script type="text/javascript" src="__STATIC__/js/uploadPreview.js"></script>

<!-- ueditor -->
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>

<script>

    // validform
    $(function () {

        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });

        // 实例化编辑器
        var ue = UE.getEditor('containers');

        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});


        // 组图排序 删除图片
        $(".toleft").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_left = item.prev(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_left.length == 0) {
                    item.insertAfter($("#photos_area").children(".item:last"));
                } else {
                    item.insertBefore(item_left);
                }
            }

        });

        $(".toright").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_right = item.next(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_right.length == 0) {
                    item.insertBefore($("#photos_area").children(".item:first"));
                } else {
                    item.insertAfter(item_right);
                }
            }
        });

        $(".del").live("click", function () {
            $(this).parent().parent(".item").remove();
        });

        $(":radio").click(function () {

            if (this.checked) {
                if ($(this).attr("id") == "freight_type_1") {
                    $("#immobilization").show();
                    $("#template").hide();
                } else {
                    $("#immobilization").hide();
                    $("#template").hide();
                }
            }
        });
    });

    // 组图上传
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn',
        url: "{:url('client/ShopGoods/uploadArr')}",
        flash_swf_url: '__STATIC__/plupload/Moxie.swf',
        silverlight_xap_url: '__STATIC__/plupload/Moxie.xap',
        filters: {
            max_file_size: '500kb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: true,
        init: {
            FilesAdded: function (up, files) {
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                var item = '';
                plupload.each(files, function (file) { //遍历文件
                    item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                });
                $("#photos_area").append(item);
                uploader.start();
            },
            UploadProgress: function (up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function (up, file, info) {

                var data = eval("(" + info.response + ")");

                $("#" + file.id).html("<input type='hidden' name='picArr[]' value='" + data.src + "'><img src='__PUBLIC__/" + data.src + "' alt='" + data.name + "' width='100px' height='100px'><div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != 0) {
                    layer.msg(data.error);
                }
            },
            Error: function (up, err) {
                layer.msg(err.message);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
            }
        }
    });
    uploader.init();


</script>
<script src="__STATIC__/js/sku.js"></script>
</body>

</html>
